package com.kelvin.paopao.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kelvin.kelvinlib.imageloader.GlideUtil;
import com.kelvin.paopao.R;
import com.kelvin.paopao.api.responseBean.DatePersonModel;

/**
 * Created by Administrator on 2017/5/11.
 */

public class DatePersonAdapter extends BaseQuickAdapter<DatePersonModel, BaseViewHolder> {
    private Context context;
    private boolean isCanCheck;

    public boolean isCanCheck() {
        return isCanCheck;
    }

    public void setCanCheck(boolean canCheck) {
        isCanCheck = canCheck;
    }

    public DatePersonAdapter(Context context) {
        super(R.layout.recycler_date_person_item);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, DatePersonModel item) {
        ImageView iv = helper.getView(R.id.iv_touxiang);
//        GlideUtil.loadCommonImg(i);
        GlideUtil.loadCommonImg(item.getUser_headimg(), R.drawable.default_img, iv, context);
        helper.setText(R.id.tv_name, item.getUser_name());
        if (item.getUser_sex() == 1) {
            helper.setImageResource(R.id.iv_gender, R.drawable.icon_male_color);
        } else {
            helper.setImageResource(R.id.iv_gender, R.drawable.icon_female_color);
        }

        if (isCanCheck) {
            helper.setBackgroundRes(R.id.tv_date_him, R.drawable.shape_date_btn);
        } else {
            helper.setBackgroundRes(R.id.tv_date_him, R.drawable.shape_login2_btn);
        }

        helper.addOnClickListener(R.id.iv_touxiang);
        helper.addOnClickListener(R.id.tv_date_him);
    }
}
